package com.ehotting.mqbd.zw.api.domain.netty;


import com.ehotting.mqbd.zw.api.constants.ActionConstants;
import com.ehotting.mqbd.zw.api.domain.protoc.ZwJobOptOuterClass;
import com.google.protobuf.InvalidProtocolBufferException;

/**
 * C->S
 * 当ZwTaskScheduleMngr与ZwSim之间网络异常断开，再次连接时，
 * ZwSim也会将本机提交到ZwTaskScheduleMngr上的job注册到ZwTaskScheduleMngr
 */
public class JobRegReq extends ZwCommPacket {

    private ZwJobOptOuterClass.ZwJobReg zwJobReg;

    public JobRegReq() {
        super(ActionConstants.Cmd_JobRegStr);
    }

    @Override
    public void convertToHexStr() {
        if (zwJobReg!=null){
            this.setBuff(zwJobReg.toByteArray());
        }
    }

    @Override
    public void convertToProp() {
        byte[] buff = this.getBuff();
        int bufSize = this.getHead().getBufSize();
        if (buff==null||bufSize==0){
            return;
        }
        try {
             this.zwJobReg = ZwJobOptOuterClass.ZwJobReg.parseFrom(buff);
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        JobRegReq req = new JobRegReq();
        System.out.println(req.toString());

    }
}
